#ifndef PAINTCHANNEL_H
#define PAINTCHANNEL_H

#include <QMap>
#include <QPixmap>
#include <QVector>
#include <QWidget>
#include "QLabel"
#include "plot/paintsettings.h"

class QToolButton;
class PaintSettings;

class PaintChannel: public QWidget
{
    Q_OBJECT

public:
    PaintChannel(QWidget *parent = 0);
    void setPlotSettings(const PaintSettings &settings);
    void setCurveData(const QVector<QPointF> &data);
    void clearCurve(int id);
    QSize minimumSizeHint() const;
    QSize sizeHint() const;
    void setPhasic(int phasic);
    int getPhasic();
public slots:
    void zoomIn();
    void zoomOut();

protected:
    void paintEvent(QPaintEvent *event);
    void resizeEvent(QResizeEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void keyPressEvent(QKeyEvent *event);
    void wheelEvent(QWheelEvent *event);
private:
    int phasic;
    void updateRubberBandRegion();
    void refreshPixmap();
    void drawGrid(QPainter *painter);
    void drawCurves(QPainter *painter);
    enum
    {
        Margin = 70
             };
    QVector<PaintSettings> zoomStack;
    QVector<QPointF> data;
    int curZoom;
    bool rubberBandIsShown;
    QRect rubberBandRect;
    QPixmap pixmap;
    QToolButton *zoomInButton;
    QToolButton *zoomOutButton;

};

#endif
